package web;

import service.CourseService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class SelectCourseServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String sid=req.getParameter("sid");
        int cid=Integer.parseInt(req.getParameter("cid"));
        boolean result=CourseService.pickCourse(sid,cid);
        if(result){
            resp.sendRedirect("self.jsp");
        }else {
            resp.getWriter().write("fail");
        }
    }
}
